
	 function selectData()
	 {	
	 	$("#selectForm").submit();
	 }

	function toInsertDiv(url){
		$("#SHOW_DIV_1").lightbox_me({
			 centered: false
			,modalCSS:{top:'20px'}
			,onClose:function(){clearFormValue('insert-update-Form');}
		});
		$('#insert-update-but').attr("onclick","insert("+url+");");
	}
	
	function insert(url){
		var param = $("#insert-update-Form").serialize();
		$.post(url 
			,param 
				,function(rs) {
					if(rs.code==0){
						selectData();
					}else{
						alert('操作失败');
					}
				}
		   ,'json');
		
		clearFormValue('insert-update-Form');
	}

	function toUpdateDiv(id,url){
		$("#SHOW_DIV_1").lightbox_me({
			centered: false
			,modalCSS:{top:'20px'}
			,onLoad:function(){
				var url = "/commonSys/manager/monitor/selectServerById.shtml";
				var param = {id:id};
				$.post(url 
					,param 
						,function(rs) {
							if(rs.code==0){
								fillTemplateValue("insert-update-Form",rs.data);
							}
						}
				   ,'json');
			}
			,onClose:function(){clearFormValue('insert-update-Form');}
		});
	}
	

	function update(url){
		var param = $("#insert-update-Form").serialize();
		$.post(url 
			,param 
				,function(rs) {
					if(rs.code==0){
						selectData();
					}
				}
		   ,'json');
		
		clearFormValue('insert-update-Form');
	}
	
	function fillTemplateValue(boxId,json){
		var keys = new Array("id","server_name","ip","port","pc_room","type"); //这个要自定义
		for(var i=0;i<keys.length;i++){
			var e1 = $("#insert-update-Form [name*="+keys[i]+"]");
			if(e1.prop("nodeName")=="TEXTAREA"){
				e1.html(json[keys[i]]);
			}else if(e1.prop("nodeName")=="INPUT" || e1.prop("nodeName")=="SELECT" ){
				e1.val(json[keys[i]]);
			}
		}
		$('#insert-update-but').attr("onclick","update();");
	}

	function clearFormValue(fId){
		$('#'+fId)[0].reset();
	}